package com.web44.mapper;

import com.web44.bean.Dept;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

/**
 * @Title: DeptMapper
 * @Description:
 * @Auther: py
 * @Version: 1.0
 * @create 2024/1/3 14:20
 */
public interface DeptMapper {


    @Select("select * from dept where deptno = #{deptno}")
    Dept queryDeptByDeptno(@Param("deptno") Integer deptno);



    @Select("select * from dept where deptno = #{deptno}")
    @Results(id = "deptEmpMapper",value = {
            @Result(id = true,property = "deptno",column = "deptno"),
            @Result(property = "dname",column = "dname"),
            @Result(property = "loc",column = "loc"),
            @Result(property = "emps",many = @Many(
                    select = "com.web44.mapper.EmpMapper.queryEmpByDeptno",
                    fetchType = FetchType.LAZY
            ),column = "deptno")
    })
    Dept queryDeptEmpByDeptno(@Param("deptno") Integer deptno);




}
